import 'package:flutter/material.dart';

class Page1 extends StatefulWidget {
  @override
  _Page1State createState() => _Page1State();
}

class _Page1State extends State<Page1> with AutomaticKeepAliveClientMixin {
  String _text1 = "page1";

  @override
  void initState() {
    print("init1");
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    super.build(context);
    print("build page1");
    return Scaffold(
      appBar: AppBar(
        title: Text("page1"),
      ),
      body: Center(
        child: Column(
          children: <Widget>[
            Text(_text1),
            FlatButton(
              onPressed: () {
                _text1 = "page111";
                setState(() {});
              },
              child: Text("change"),
            )
          ],
        ),
      ),
    );
  }

  @override
  bool get wantKeepAlive => true;
}
